//右上角二维码
const qrCode = document.querySelector('.login-swith')
const tip = document.querySelector('.login-way-tip')

qrCode.addEventListener('mouseover',function(){
  tip.style.opacity = "1"
})
qrCode.addEventListener('mouseout',function(){
  tip.style.opacity = "0"
})
// 右上角二维码结束

//跳转页面
const register = document.querySelector('.register-button')
// console.log(register);
register.onclick = function(){
  window.location.href = "./register.html"
}












const form  = document.querySelector('form')
const userName = document.querySelector('#username')
const passWord = document.querySelector('#password')
// console.log(form);


form.addEventListener('submit', e => {
  e = e || window.event
  // 阻止默认行为
  try { e.preventDefault() } catch(err) { e.returnValue = false }



  const user = userName.value
  const pwd = passWord.value
  const uname = window.localStorage.username
  const pword = window.localStorage.password
  // console.log(user);
  // console.log(pwd);

  if (!user || !pwd) return alert('请完整填写表单')
  // console.log(localStorage);
  if( user === uname && pwd === pword){
    // console.log('111');
    alert('登录成功')
    window.location.href = './index.html'
    
  }else{
    alert('用户名或密码错误')
  }

})